package com.lemon.smartsafetynew.ui.fragment.air;

import android.os.Bundle;

import com.lemon.android.http.LemonRequestParams;
import com.lemon.smartsafety.app.RefreshType;
import com.lemon.smartsafety.listener.RecyclerTClickListener;
import com.lemon.smartsafetynew.ui.fragment.base.BasePullToRefreshFragment;
import com.lemon.smartsafety.utils.app.UIHelper;
import com.lemon.smartsafetynew.entity.electrical.ElectricalCompanyVo;
import com.lemon.smartsafetynew.net.services.MonitorServices;
import com.lemon.smartsafetynew.ui.activity.air.AirListActivity;
import com.lemon.smartsafetynew.ui.adapter.electrical.ElectricalCompanyAdapter;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

import java.util.List;

import kale.adapter.LemonRcvAdapter;

/**
 * 实时监测 -- 有可燃/有毒气体的企业列表
 * Created by Andrew on 2018/3/17.
 */

public class AirCompanyListFragment extends BasePullToRefreshFragment<ElectricalCompanyVo, List<ElectricalCompanyVo>>
        implements RecyclerTClickListener<ElectricalCompanyVo> {

    public static AirCompanyListFragment newInstance() {

        Bundle args = new Bundle();

        AirCompanyListFragment fragment = new AirCompanyListFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onItemClick(ElectricalCompanyVo data, int position) {
        Bundle bundle = new Bundle();
        bundle.putSerializable(KeyConstants.KEY_ELECTRICAL_COMPANY_INFO, data);
        UIHelper.showActivity(getmContext(), bundle, AirListActivity.class);
    }

    @Override
    public void onPullRefresh() {
        LemonRequestParams params = new LemonRequestParams("");
        params.put("pageNum", currentPage);
        params.put("pageSize", pageSize);
        MonitorServices.init().getMonitorVideoCompanyList(RefreshType.REFRESH, params);
    }

    @Override
    public void onLoadMore() {
        LemonRequestParams params = new LemonRequestParams("");
        params.put("pageNum", currentPage);
        params.put("pageSize", pageSize);
        MonitorServices.init().getMonitorVideoCompanyList(RefreshType.LOAD_MORE, params);
    }

    @Override
    public boolean goRefreshOnCreate() {
        return true;
    }

    @Override
    public LemonRcvAdapter<ElectricalCompanyVo> getLemonAdapter() {
        return new ElectricalCompanyAdapter(mDataList, this);
    }

    @Override
    public String getHttpTag() {
        return KeyConstants.URL_GET_MONITOR_HAS_VIDEO_COMPANY_LIST;
    }

}